package edu.nctu.csie.jichang.database.util;

import java.util.List;

import edu.nctu.csie.jichang.database.model.cell.ColumnInfoValue;

public class SQLUtil {

	public static String getInsertSQL(String pTableName, List<ColumnInfoValue> pList) throws Exception {
		StringBuffer tSQL = new StringBuffer();
		StringBuffer tValue = new StringBuffer();
		tSQL.append("Insert Into ").append(pTableName).append(" ( ");
		for (ColumnInfoValue s: pList){
			tSQL.append(s.getColumnInfo().getName()).append(",");
			tValue.append(s.toSQL()).append(",");
		}
		tSQL.deleteCharAt(tSQL.length()-1);
		tValue.deleteCharAt(tValue.length()-1);
		tSQL.append(" ) Values ( ").append(tValue).append(" ) ");
		return tSQL.toString();
	}
}
